#pragma once
#include <string>
#include <iostream>
#include <cstdio>

class task
{
public:
    task() {}
    task(int x, int y, char op)
        : _num_x(x), _num_y(y), _operator(op)
    {}

    std::string operator()()
    {
        int rt_val = -1;
        switch (_operator)
        {
        case '+':
            rt_val = _num_y + _num_x;
            break;

        case '-':
            rt_val = _num_x - _num_y;
            break;

        case '*':
            rt_val = _num_x * _num_y;
            break;

        case '/':
        {
            if (_num_y == 0)
                std::cout << "div zero error" << std::endl;
            else
                rt_val = _num_x / _num_y;
            break;
        }

        case '%':
        {
            if (_num_y == 0)
                std::cout << "mod zero error" << std::endl;
            else
                rt_val = _num_x % _num_y;
            break;
        }

        default:
            std::cout << "operator not support" << std::endl;
            break;
        }

        char buff[64];
        snprintf(buff, sizeof(buff) - 1, "%d %c %d = %d", _num_x, _operator, _num_y, rt_val);
        std::cout << "这是在处理函数内部， 处理结果：" << buff << std::endl;
        return buff;
    }

    std::string task_name()
    {
        char buff[64];
        snprintf(buff, sizeof buff, "%d %c %d = ?", _num_x, _operator, _num_y);
        return buff;
    }

private:
    int _num_x;
    int _num_y;
    char _operator;
};